import layoutHeaderAside from '@/layout/header-aside'

// 由于懒加载页面太多的话会造成webpack热更新太慢，所以开发环境不使用懒加载，只有生产环境使用懒加载
const _import = require('@/libs/util.import.' + process.env.NODE_ENV)

/**
 * 在主框架内显示
 */
const frameIn = [{
  path: '/',
  redirect: {
    name: 'index'
  },
  component: layoutHeaderAside,
  children: [
    // 首页
    {
      path: 'index',
      name: 'index',
      meta: {
        auth: true
      },
      component: _import('system/index')
    },
    //商品界面
    {
      path: 'product',
      name: 'product',
      meta: {
        title: '产品类表',
        auth: true
      },
      component: _import('product/product')
    },
    {
      path: 'addProduct',
      name: 'addProduct',
      meta: {
        title: '添加商品',
        auth: true
      },
      component: _import('product/product/addProduct')
    },
    {
      path: 'productCategory',
      name: 'productCategory',
      meta: {
        title: '分类管理',
        auth: true
      },
      component: _import('product/productCategory')
    },
    //促销管理
    {
      path: 'promotion/coupon',
      name: 'coupon',
      meta: {
        title: '优惠券',
        auth: true
      },
      component: _import('promotion/coupon')
    },
    {
      path: 'coupon/addCoupon',
      name: 'addCoupon',
      meta: {
        title: '添加优惠券',
        auth: true
      },
      component: _import('promotion/coupon/addCoupon')
    },
    //订单管理
    {
      path: 'order/productOrder',
      name: 'productOrder',
      meta: {
        title: '订单管理',
        auth: true
      },
      component: _import('order/productOrder')
    },
    //系统设置
    {
      path: 'settings',
      name: 'settings',
      meta: {
        title: '站点设置',
        auth: true
      },
      component: _import('system/website/settings')
    },
    // 客服
    {
      path: '/customer/servicemsg',
      name: 'servicemsg',
      meta: {
        title: '客服管理',
        auth: true
      },
      component: _import('customer/servicemsg')
    },
    // 网盘
    {
      path: '/netdisk/storeNetdisk',
      name: 'storeNetdisk',
      meta: {
        title: '商家网盘',
        auth: true
      },
      component: _import('netdisk/storeNetdisk')
    },
    // 系统 前端日志
    {
      path: 'log',
      name: 'log',
      meta: {
        title: '前端日志',
        auth: true
      },
      component: _import('system/log')
    },
    // 刷新页面 必须保留
    {
      path: 'refresh',
      name: 'refresh',
      hidden: true,
      component: _import('system/function/refresh')
    },
    // 页面重定向 必须保留
    {
      path: 'redirect/:route*',
      name: 'redirect',
      hidden: true,
      component: _import('system/function/redirect')
    }
  ]
}]

/**
 * 在主框架之外显示
 */
const frameOut = [
  // 登录
  {
    path: '/login',
    name: 'login',
    component: _import('system/login')
  }
]

/**
 * 错误页面
 */
const errorPage = [{
  path: '*',
  name: '404',
  component: _import('system/error/404')
}]

// 导出需要显示菜单的
export const frameInRoutes = frameIn

// 重新组织后导出
export default [
  ...frameIn,
  ...frameOut,
  ...errorPage
]